<%--
  Created by IntelliJ IDEA.
  User: dzw
  Date: 2017/12/4
  Time: 16:08
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ page isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
  String path = request.getContextPath();
  String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";

%>

<div id="page-content">
  <input type="hidden" id="parentId" value="${parentId}" />
  <div class="row">

    <%--<div class="col-lg-12">--%>
      <div class="panel">
        <div class="panel-heading">
          <h3 class="panel-title">开票收款登记</h3>
        </div>
        <div class="panel-body">
          <div class="form-inline">
            <div class="row">
              <div class="col-sm-12 table-toolbar-left">
                <btn id="btn_add_billing" class="btn btn-primary btn-sm" onClick="addDetail('billing')">
                  <i class="ti-plus"> </i> 新建进款计划
                </btn>
                <btn id="btn_cancel_receipts" class="btn btn-warning btn-sm pull-right" onClick="addDetail('receipts')">
                  <i class="ti-plus"> </i> 进款登记
                </btn>
              </div>
            </div>
          </div>
          <div class="table-jqgrid col-md-6" style="float: left;padding: 0">
            <table id="billing_table"></table>
            <div id="billing_page"></div>
          </div>
          <div class="table-jqgrid col-md-6" style="padding: 0">
            <table id="receipts_table"></table>
            <div id="receipts_page"></div>
          </div>
        </div>
      </div>
    <%--</div>--%>

  </div>
</div>

<script>

  $(function(){

    init_grid_billing();
    init_grid_receipts();

    jQuery("#billing_table").jqGrid('setGridWidth', table_global_width/2-40);
    jQuery("#receipts_table").jqGrid('setGridWidth', table_global_width/2-40);

  });

  function init_grid_billing() {
        __init_jqgrid('billing_table', 'billing_page',
                '<%=path%>/com/contractPerform/detailList?type=billing&parentId='+$("#parentId").val(),
                ['开票日期',"开票金额（元）","id"],
                [
                  {name:'date',index:'date', width:100,search:true,sortable:true, searchoptions: {sopt: ['cn']}},
                  {name:'money',index:'money', width:100,sortable:true,search:true, searchoptions: {sopt: ['cn']}},
                  {name:'id',index:'id',search:false,hidden:true}
                ],
                true,true
        );
  }

  function init_grid_receipts() {
        __init_jqgrid('receipts_table', 'receipts_page',
                '<%=path%>/com/contractPerform/detailList?type=receipts&parentId='+$("#parentId").val(),
                ['进款日期',"进款金额（元）","id"],
                [
                  {name:'date',index:'date', width:100,search:true,sortable:true, searchoptions: {sopt: ['cn']}},
                  {name:'money',index:'money', width:100,sortable:true,search:true, searchoptions: {sopt: ['cn']}},
                  {name:'id',index:'id',search:false,hidden:true}
                ],
                true,true
        );
  }

  function addDetail(type) {
      var url = '<%=path%>/com/contractPerform/addDetailPage?parentId='+$("#parentId").val()+'&type='+type;
      __open_dialog_form('履约登记', url, function (dialogRef) {
          var callback = function (data) {
              if (data) {
                  dialogRef.close();
                  $('#billing_table').jqGrid().setGridParam({datatype:'json'}).trigger('reloadGrid');
                  $('#receipts_table').jqGrid().setGridParam({datatype:'json'}).trigger('reloadGrid');
//                    __toastr_info("履约登记操作成功！");
              } else {
                  dialogRef.enableButtons();
              }
          };
          if (fn_task_feedback_save(callback) === false) {
//                __toastr_error("任务反馈操作失败！");
              dialogRef.enableButtons();
          }
      });
  }


</script>